<?php 
include("conexion.php");

$codkardex = $_POST['codkardex'];

$consulta = mysql_query("SELECT tip_documen.des_docum AS 'tip_docu', CONCAT(m_cteventas.serie,'-',m_cteventas.documento) AS 'num_docu', DATE_FORMAT(m_cteventas.fecha,'%d/%m/%Y') AS 'fec_emision', 
(CASE WHEN m_cteventas.swt_est='T' THEN 'PAGADO' ELSE 'NO PAGADO' END) AS 'condicion', 
m_cteventas.importe AS 'precio_vta', m_cteventas.saldo AS 'saldo'
FROM m_cteventas
INNER JOIN tip_documen ON tip_documen.id_documen = m_cteventas.tipo_docu
WHERE m_cteventas.kardex = '$codkardex'", $conn) or die(mysql_error());
$i = 1;
while($row = mysql_fetch_array($consulta)){
echo "<table id='detPagosTb' width='100%' border='1' cellspacing='0' cellpadding='0'>
  <tr class='well' style='cursor:pointer'>
    <td width='70'  align='left'><label style='color:#333333'>".$row['tip_docu']."</label></td>
    <td width='100' align='center' ><label style='color:#333333'>".$row['num_docu']."</label></td>
	<td width='72'  align='center' ><label style='color:#333333'>".$row['fec_emision']."</label></td>
	<td width='106' align='center'><label style='color:#333333'>".$row['condicion']."</label></td>
	<td width='70'  align='right' ><label style='color:#333333'>".$row['precio_vta']."</label></td>
	<td width='70'  align='right' ><label style='color:#333333'>".$row['saldo']."</label></td>
	<td style='display:none'><input id='datosTb".$i."' type='text' value='".$row['tip_docu']."|".$row['num_docu']."|".$row['fec_emision']."|".$row['condicion']."|".$row['precio_vta']."|".$row['saldo']."' /></td>
  </tr>
</table>";
$i++;
} 
?>
